import "package:flutter/material.dart";

// https://github.com/mennorenkens/flutter_scrolling_calendar/tree/develop
import '../../../widget/calendar4/scrolling_years_calendar.dart';

class CalendarPage4 extends StatelessWidget {
    final String text;
    
    CalendarPage4({Key key, this.text}) : super(key: key);

    List<DateTime> getHighlightedDates() {
        return List<DateTime>.generate(
            10,
                (int index) => DateTime.now().add(Duration(days: 10 * (index + 1))),
        );
    }
    
    @override
    Widget build(BuildContext context) {
        return Scaffold(
            appBar: PreferredSize(
                preferredSize: Size.fromHeight(36.0),
                child: AppBar(
                    centerTitle: true,
                    elevation: 0.5,
                    titleSpacing: 0.0,
                    title: Text(text),
                ),
            ),
            body: ScrollingYearsCalendar(
                // Required properties
                context: context,
                initialDate: DateTime.now(),
                firstDate: DateTime.now().subtract(const Duration(days: 5 * 365)),
                lastDate: DateTime.now(),
                currentDateColor: Colors.blue,
    
                // Optional properties
                highlightedDates: getHighlightedDates(),
                highlightedDateColor: Colors.deepOrange,
                monthNames: const <String>[
                    'Jan',
                    'Feb',
                    'Mar',
                    'Apr',
                    'May',
                    'Jun',
                    'Jul',
                    'Aug',
                    'Sep',
                    'Oct',
                    'Nov',
                    'Dec',
                ],
                onMonthTap: (int year, int month) => print('Tapped $month/$year'),
            ),
        );
    }
}
